home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Testing & Debugging / Memory Management / DisposeResource init / DisposeResource release notes next >
Encoding:
Text File  |  1993-09-17  |  1.4 KB  |  30 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    DisposeResource - by Greg Marriott
  3. ;
  4. ;    © 1992, Apple Computer, Inc.
  5. ;
  6. ;    DisposeResource is a debugging utility made to catch a common programming error:
  7. ;    passing a resource handle to _DisposeHandle.
  8. ;
  9. ;    The Resource Manager keeps track of in-memory resources by storing their handles
  10. ;    in the resource map.  If the block used by the resource is freed without letting the
  11. ;    resource manager know (by calling _ReleaseResource), then the handle reference will
  12. ;    not be removed from the resource map.  This can lead to crashes and data loss.
  13. ;    
  14. ;    Future allocations in the heap will likely re-use the master pointer for another
  15. ;    relocatable block.  If this happens, then the handle returned to the client will
  16. ;    be the same value as the handle in the resource map.  Magically (or sadly), the 
  17. ;    handle in the map will now suddenly refer to a random block in the heap.  This data
  18. ;    could be written out to the resource file, or trashed if _LoadResource is called on
  19. ;    the “resource” handle.
  20. ;
  21. ;    DisposeResource will break into the debugger if _DisposeHandle is ever passed a handle
  22. ;    referring to a block with the resource attribute set.  This usually will be a resourc
  23. ;    handle, but be aware that the resource attribute COULD be set on a non-resource handle.
  24. ;    This isn’t likely (unless someone was a complete bonehead), but it’s possible.
  25. ;    
  26. ;    Greg Marriott
  27. ;    Just Some Guy
  28. ;    Apple Computer, Inc.
  29. ;    20525 Mariani Ave. MS/81-GC
  30. ;    Cupertino, CA    95014